package com.ruoyi.web.controller.operation;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GwSector;
import com.ruoyi.system.service.IGwSectorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 行业Controller
 * 
 * @author ruoyi
 * @date 2025-05-08
 */
@Api(description = "平台运营管理-行业")
@RestController
@RequestMapping("/system/sector")
public class GwSectorController extends BaseController
{
    @Autowired
    private IGwSectorService gwSectorService;

    /**
     * 查询行业列表
     */
    @ApiOperation("查询行业列表-分页")
    @GetMapping("/list")
    public TableDataInfo list(GwSector gwSector)
    {
        startPage();
        List<GwSector> list = gwSectorService.selectGwSectorList(gwSector);
        return getDataTable(list);
    }

    /**
     * 查询行业列表--无分页
     */
    @ApiOperation("查询行业列表-无分页")
    @GetMapping("/sectorList")
    public AjaxResult sectorList(GwSector gwSector)
    {
        List<GwSector> list = gwSectorService.selectGwSectorList(gwSector);
        return AjaxResult.success(list);
    }

    /**
     * 导出行业列表
     */
//    @PreAuthorize("@ss.hasPermi('system:sector:export')")
    @Log(title = "行业", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GwSector gwSector)
    {
        List<GwSector> list = gwSectorService.selectGwSectorList(gwSector);
        ExcelUtil<GwSector> util = new ExcelUtil<GwSector>(GwSector.class);
        util.exportExcel(response, list, "行业数据");
    }

    /**
     * 获取行业详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:sector:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(gwSectorService.selectGwSectorById(id));
    }

    /**
     * 新增行业
     */
//    @PreAuthorize("@ss.hasPermi('system:sector:add')")
    @Log(title = "行业", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GwSector gwSector)
    {
        return toAjax(gwSectorService.insertGwSector(gwSector));
    }

    /**
     * 修改行业
     */
//    @PreAuthorize("@ss.hasPermi('system:sector:edit')")
    @Log(title = "行业", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GwSector gwSector)
    {
        return toAjax(gwSectorService.updateGwSector(gwSector));
    }

    /**
     * 删除行业
     */
    @PreAuthorize("@ss.hasPermi('system:sector:remove')")
    @Log(title = "行业", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(gwSectorService.deleteGwSectorByIds(ids));
    }
}
